/*==============================================================================
  项目名称: Auto数据集分析脚本
  创建日期: 2025-10-26
  描述: 使用Stata内置auto.dta数据集进行数据处理和分析
==============================================================================*/

* 清空内存和关闭所有日志
clear all
set more off
capture log close

* 设置工作目录（根据需要修改）
* cd "你的工作目录路径"

* 开启日志记录
log using "auto_analysis_log.smcl", replace

/*------------------------------------------------------------------------------
  1. 数据加载
------------------------------------------------------------------------------*/
* 加载Stata内置的auto数据集
sysuse auto, clear

* 查看数据基本信息
describe
summarize

/*------------------------------------------------------------------------------
  2. 数据探索
------------------------------------------------------------------------------*/
* 查看前10条观测
list in 1/10

* 查看数据结构
codebook make price mpg weight

* 按变量类型分类汇总
summarize price mpg weight length, detail

* 按分类变量汇总
tabulate foreign
tabulate rep78

/*------------------------------------------------------------------------------
  3. 数据清理
------------------------------------------------------------------------------*/
* 检查缺失值
misstable summarize
misstable patterns

* 处理缺失值 - 用中位数填充rep78的缺失值
egen rep78_median = median(rep78)
replace rep78 = rep78_median if missing(rep78)
drop rep78_median

/*------------------------------------------------------------------------------
  4. 变量生成和转换
------------------------------------------------------------------------------*/
* 生成新变量：价格分类
generate price_category = .
replace price_category = 1 if price < 5000
replace price_category = 2 if price >= 5000 & price < 10000
replace price_category = 3 if price >= 10000 & !missing(price)

label define price_cat_lbl 1 "低价" 2 "中价" 3 "高价"
label values price_category price_cat_lbl
label variable price_category "价格分类"

* 生成新变量：油耗等级（每加仑英里数）
generate mpg_rating = ""
replace mpg_rating = "低效" if mpg < 20
replace mpg_rating = "中等" if mpg >= 20 & mpg < 25
replace mpg_rating = "高效" if mpg >= 25 & !missing(mpg)

* 生成新变量：重量（吨）
generate weight_ton = weight / 2000
label variable weight_ton "重量（吨）"

* 生成新变量：每磅价格
generate price_per_lb = price / weight
label variable price_per_lb "每磅价格"

* 生成新变量：是否豪华车（价格>10000且国外品牌）
generate luxury = (price > 10000 & foreign == 1)
label variable luxury "豪华车标识"

/*------------------------------------------------------------------------------
  5. 数据分组和汇总
------------------------------------------------------------------------------*/
* 按国产/进口分组统计
bysort foreign: summarize price mpg weight

* 按价格分类统计
bysort price_category: summarize mpg weight

* 生成分组统计变量
bysort foreign: egen avg_price_by_origin = mean(price)
bysort foreign: egen avg_mpg_by_origin = mean(mpg)

label variable avg_price_by_origin "按产地分组的平均价格"
label variable avg_mpg_by_origin "按产地分组的平均油耗"

/*------------------------------------------------------------------------------
  6. 数据排序和筛选
------------------------------------------------------------------------------*/
* 按价格降序排序
sort price
gsort -price

* 筛选高价车（价格>8000）
preserve
keep if price > 8000
list make price mpg foreign in 1/10
restore

* 筛选进口车
preserve
keep if foreign == 1
summarize price mpg weight
restore

/*------------------------------------------------------------------------------
  7. 变量重命名和标签
------------------------------------------------------------------------------*/
* 重命名变量
rename mpg miles_per_gallon
rename rep78 repair_record

* 添加变量标签
label variable miles_per_gallon "每加仑英里数"
label variable repair_record "1978年维修记录"

* 添加值标签
label define foreign_lbl 0 "国产" 1 "进口"
label values foreign foreign_lbl

/*------------------------------------------------------------------------------
  8. 创建交叉表
------------------------------------------------------------------------------*/
* 简单交叉表
tabulate foreign price_category

* 带统计量的交叉表
tabulate foreign price_category, chi2 row col

* 双向表格统计
* Stata 17+新语法
table foreign price_category, statistic(mean price) statistic(mean miles_per_gallon)

* 或使用传统的tabstat命令（兼容所有版本）
* tabstat price miles_per_gallon, by(foreign) statistics(mean) columns(statistics)

/*------------------------------------------------------------------------------
  9. 条件统计
------------------------------------------------------------------------------*/
* 计算条件均值
summarize price if foreign == 1
summarize price if foreign == 0

* 按条件生成统计量
egen price_p25 = pctile(price), p(25)
egen price_p75 = pctile(price), p(75)

display "价格25分位数: " price_p25
display "价格75分位数: " price_p75

/*------------------------------------------------------------------------------
  10. 生成分析图表
------------------------------------------------------------------------------*/
* 确保输出目录存在
capture mkdir "../dataset"
capture mkdir "../dataset/graphs"

* 图1: 价格分布直方图
histogram price, frequency normal ///
    title("汽车价格分布") ///
    xtitle("价格 (美元)") ytitle("频数") ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/price_histogram.png", replace

* 图2: 按产地分组的价格箱线图
graph box price, over(foreign) ///
    title("国产车与进口车价格比较") ///
    ytitle("价格 (美元)") ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/price_by_origin_boxplot.png", replace

* 图3: 油耗与重量的散点图
twoway (scatter miles_per_gallon weight, mcolor(blue) msize(medium)) ///
       (lfit miles_per_gallon weight, lcolor(red)), ///
    title("油耗与重量关系") ///
    xtitle("重量 (磅)") ytitle("每加仑英里数") ///
    legend(label(1 "观测值") label(2 "拟合线")) ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/mpg_weight_scatter.png", replace

* 图4: 按产地和价格分类的油耗对比
graph bar miles_per_gallon, over(price_category) over(foreign) ///
    asyvars ///
    title("不同价格区间和产地的平均油耗") ///
    ytitle("每加仑英里数") ///
    legend(label(1 "国产") label(2 "进口")) ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/mpg_by_price_origin.png", replace

* 图5: 价格与油耗的散点图（按产地分色）
twoway (scatter price miles_per_gallon if foreign==0, mcolor(blue) msize(medium)) ///
       (scatter price miles_per_gallon if foreign==1, mcolor(red) msize(medium)), ///
    title("价格与油耗关系") ///
    xtitle("每加仑英里数") ytitle("价格 (美元)") ///
    legend(label(1 "国产") label(2 "进口")) ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/price_mpg_scatter.png", replace

* 图6: 价格分类的饼图
graph pie, over(price_category) ///
    title("汽车价格分类分布") ///
    plabel(_all percent, format(%9.1f)) ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/price_category_pie.png", replace

* 图7: 重量分布直方图（按产地分组）
histogram weight, by(foreign) frequency ///
    title("汽车重量分布") ///
    subtitle("按产地分组") ///
    xtitle("重量 (磅)") ytitle("频数") ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/weight_histogram_by_origin.png", replace

* 图8: 维修记录分布条形图
graph bar (count), over(repair_record) over(foreign) asyvars ///
    title("维修记录分布") ///
    ytitle("车辆数量") ///
    legend(label(1 "国产") label(2 "进口")) ///
    note("数据来源: auto.dta")
graph export "../dataset/graphs/repair_record_bar.png", replace

/*------------------------------------------------------------------------------
  11. 生成结果表
------------------------------------------------------------------------------*/
* 确保latex输出目录存在
capture mkdir "../dataset/latex"

* 表1: 描述性统计表
preserve

* 使用summarize生成统计量并保存
quietly {
    * 创建临时文件存储统计结果
    tempname memhold
    postfile `memhold' str30 variable count mean sd min max using "../dataset/descriptive_stats_temp.dta", replace

    foreach var in price miles_per_gallon weight length turn displacement {
        summarize `var'
        post `memhold' ("`var'") (r(N)) (r(mean)) (r(sd)) (r(min)) (r(max))
    }
    postclose `memhold'
}

* 加载并导出为CSV
use "../dataset/descriptive_stats_temp.dta", clear
export delimited using "../dataset/descriptive_stats.csv", replace

* 导出LaTeX格式
file open latextab using "../dataset/latex/descriptive_stats.tex", write replace
file write latextab "\begin{table}[htbp]" _n
file write latextab "\centering" _n
file write latextab "\caption{描述性统计表\label{tab:descriptive}}" _n
file write latextab "\begin{tabular}{lrrrrr}" _n
file write latextab "\toprule" _n
file write latextab "变量 & 观测数 & 均值 & 标准差 & 最小值 & 最大值 \\" _n
file write latextab "\midrule" _n

* 写入数据行
local N = _N
forvalues i = 1/`N' {
    local var = variable[`i']
    local cnt = string(count[`i'], "%9.0f")
    local mn = string(mean[`i'], "%9.2f")
    local sd = string(sd[`i'], "%9.2f")
    local min = string(min[`i'], "%9.2f")
    local max = string(max[`i'], "%9.2f")
    file write latextab "`var' & `cnt' & `mn' & `sd' & `min' & `max' \\" _n
}

file write latextab "\bottomrule" _n
file write latextab "\end{tabular}" _n
file write latextab "\end{table}" _n
file close latextab

* 清理临时文件
erase "../dataset/descriptive_stats_temp.dta"
restore

* 表2: 按产地分组的汇总统计
preserve
collapse (mean) mean_price=price mean_mpg=miles_per_gallon mean_weight=weight ///
         (sd) sd_price=price sd_mpg=miles_per_gallon sd_weight=weight ///
         (min) min_price=price min_mpg=miles_per_gallon ///
         (max) max_price=price max_mpg=miles_per_gallon ///
         (count) n=price, by(foreign)

* 添加标签
label variable foreign "产地"
label variable mean_price "平均价格"
label variable mean_mpg "平均油耗"
label variable mean_weight "平均重量"
label variable sd_price "价格标准差"
label variable sd_mpg "油耗标准差"
label variable sd_weight "重量标准差"
label variable min_price "最低价格"
label variable max_price "最高价格"
label variable min_mpg "最低油耗"
label variable max_mpg "最高油耗"
label variable n "样本量"

list

* 导出CSV格式
export delimited using "../dataset/summary_by_origin.csv", replace

* 导出LaTeX格式
file open latextab using "../dataset/latex/summary_by_origin.tex", write replace
file write latextab "\begin{table}[htbp]" _n
file write latextab "\centering" _n
file write latextab "\caption{按产地分组的汇总统计\label{tab:summary_origin}}" _n
file write latextab "\begin{tabular}{lrrrrrrrrrrrr}" _n
file write latextab "\toprule" _n
file write latextab "产地 & 平均价格 & 平均油耗 & 平均重量 & 价格标准差 & 油耗标准差 & 重量标准差 & 最低价格 & 最高价格 & 最低油耗 & 最高油耗 & 样本量 \\" _n
file write latextab "\midrule" _n

local N = _N
forvalues i = 1/`N' {
    local fg = string(foreign[`i'], "%9.0f")
    local mp = string(mean_price[`i'], "%9.2f")
    local mm = string(mean_mpg[`i'], "%9.2f")
    local mw = string(mean_weight[`i'], "%9.2f")
    local sp = string(sd_price[`i'], "%9.2f")
    local sm = string(sd_mpg[`i'], "%9.2f")
    local sw = string(sd_weight[`i'], "%9.2f")
    local minp = string(min_price[`i'], "%9.2f")
    local maxp = string(max_price[`i'], "%9.2f")
    local minm = string(min_mpg[`i'], "%9.2f")
    local maxm = string(max_mpg[`i'], "%9.2f")
    local n = string(n[`i'], "%9.0f")
    file write latextab "`fg' & `mp' & `mm' & `mw' & `sp' & `sm' & `sw' & `minp' & `maxp' & `minm' & `maxm' & `n' \\" _n
}

file write latextab "\bottomrule" _n
file write latextab "\end{tabular}" _n
file write latextab "\end{table}" _n
file close latextab
restore

* 表3: 价格分类交叉表
preserve
contract foreign price_category, freq(count)
reshape wide count, i(price_category) j(foreign)
rename count0 国产
rename count1 进口
label variable price_category "价格分类"
list

* 导出CSV格式
export delimited using "../dataset/crosstab_price_origin.csv", replace

* 导出LaTeX格式
file open latextab using "../dataset/latex/crosstab_price_origin.tex", write replace
file write latextab "\begin{table}[htbp]" _n
file write latextab "\centering" _n
file write latextab "\caption{价格分类与产地交叉表\label{tab:crosstab}}" _n
file write latextab "\begin{tabular}{lrr}" _n
file write latextab "\toprule" _n
file write latextab "价格分类 & 国产 & 进口 \\" _n
file write latextab "\midrule" _n

local N = _N
forvalues i = 1/`N' {
    local pc = string(price_category[`i'], "%9.0f")
    local dom = string(国产[`i'], "%9.0f")
    local for = string(进口[`i'], "%9.0f")
    file write latextab "`pc' & `dom' & `for' \\" _n
}

file write latextab "\bottomrule" _n
file write latextab "\end{tabular}" _n
file write latextab "\end{table}" _n
file close latextab
restore

* 表4: 相关系数矩阵
preserve
correlate price miles_per_gallon weight length displacement
matrix C = r(C)

* 导出Excel格式
putexcel set "../dataset/correlation_matrix.xlsx", replace
putexcel A1 = "相关系数矩阵"
putexcel A2 = matrix(C), names

* 导出LaTeX格式
local vars "price miles_per_gallon weight length displacement"
local nvars : word count `vars'

file open latextab using "../dataset/latex/correlation_matrix.tex", write replace
file write latextab "\begin{table}[htbp]" _n
file write latextab "\centering" _n
file write latextab "\caption{相关系数矩阵\label{tab:correlation}}" _n
file write latextab "\begin{tabular}{l" _n
forvalues i = 1/`nvars' {
    file write latextab "r"
}
file write latextab "}" _n
file write latextab "\toprule" _n
file write latextab "变量"
foreach var of local vars {
    file write latextab " & `var'"
}
file write latextab " \\" _n
file write latextab "\midrule" _n

forvalues i = 1/`nvars' {
    local var : word `i' of `vars'
    file write latextab "`var'"
    forvalues j = 1/`nvars' {
        local val = string(C[`i',`j'], "%9.3f")
        file write latextab " & `val'"
    }
    file write latextab " \\" _n
}

file write latextab "\bottomrule" _n
file write latextab "\end{tabular}" _n
file write latextab "\end{table}" _n
file close latextab
restore

* 表5: 回归分析结果表
* 模型1
quietly regress price miles_per_gallon weight foreign
matrix b1 = e(b)
matrix V1 = e(V)
local r2_1 = e(r2)
local ar2_1 = e(r2_a)
local N1 = e(N)
local vars1 "miles_per_gallon weight foreign _cons"

* 模型2
quietly regress price miles_per_gallon weight foreign displacement
matrix b2 = e(b)
matrix V2 = e(V)
local r2_2 = e(r2)
local ar2_2 = e(r2_a)
local N2 = e(N)
local vars2 "miles_per_gallon weight foreign displacement _cons"

* 导出CSV格式
file open csvfile using "../dataset/regression_results.csv", write replace
file write csvfile "变量,模型1_系数,模型1_标准误,模型2_系数,模型2_标准误" _n

* 写入模型1和模型2的系数
local maxvars : word count `vars2'
forvalues i = 1/`maxvars' {
    local var : word `i' of `vars2'
    file write csvfile "`var',"

    * 模型1系数
    local found1 = 0
    forvalues j = 1/4 {
        local v1 : word `j' of `vars1'
        if "`v1'" == "`var'" {
            local coef1 = string(b1[1,`j'], "%9.3f")
            local se1 = string(sqrt(V1[`j',`j']), "%9.3f")
            file write csvfile "`coef1',`se1',"
            local found1 = 1
        }
    }
    if `found1' == 0 {
        file write csvfile ",,"
    }

    * 模型2系数
    local coef2 = string(b2[1,`i'], "%9.3f")
    local se2 = string(sqrt(V2[`i',`i']), "%9.3f")
    file write csvfile "`coef2',`se2'" _n
}

file write csvfile "R-squared,,`r2_1',,`r2_2'" _n
file write csvfile "Adj R-squared,,`ar2_1',,`ar2_2'" _n
file write csvfile "N,,`N1',,`N2'" _n
file close csvfile

* 导出LaTeX格式
file open latextab using "../dataset/latex/regression_results.tex", write replace
file write latextab "\begin{table}[htbp]" _n
file write latextab "\centering" _n
file write latextab "\caption{回归分析结果\label{tab:regression}}" _n
file write latextab "\begin{tabular}{lrrrr}" _n
file write latextab "\toprule" _n
file write latextab " & \multicolumn{2}{c}{模型1} & \multicolumn{2}{c}{模型2} \\" _n
file write latextab "\cmidrule(lr){2-3} \cmidrule(lr){4-5}" _n
file write latextab "变量 & 系数 & 标准误 & 系数 & 标准误 \\" _n
file write latextab "\midrule" _n

* 写入系数
forvalues i = 1/`maxvars' {
    local var : word `i' of `vars2'
    file write latextab "`var' & "

    * 模型1
    local found1 = 0
    forvalues j = 1/4 {
        local v1 : word `j' of `vars1'
        if "`v1'" == "`var'" {
            local coef1 = string(b1[1,`j'], "%9.3f")
            local se1 = string(sqrt(V1[`j',`j']), "%9.3f")
            file write latextab "`coef1' & `se1' & "
            local found1 = 1
        }
    }
    if `found1' == 0 {
        file write latextab " & & "
    }

    * 模型2
    local coef2 = string(b2[1,`i'], "%9.3f")
    local se2 = string(sqrt(V2[`i',`i']), "%9.3f")
    file write latextab "`coef2' & `se2' \\" _n
}

file write latextab "\midrule" _n
file write latextab "R-squared & \multicolumn{2}{c}{" %9.3f `r2_1' "} & \multicolumn{2}{c}{" %9.3f `r2_2' "} \\" _n
file write latextab "Adj R-squared & \multicolumn{2}{c}{" %9.3f `ar2_1' "} & \multicolumn{2}{c}{" %9.3f `ar2_2' "} \\" _n
file write latextab "N & \multicolumn{2}{c}{`N1'} & \multicolumn{2}{c}{`N2'} \\" _n
file write latextab "\bottomrule" _n
file write latextab "\end{tabular}" _n
file write latextab "\end{table}" _n
file close latextab

/*------------------------------------------------------------------------------
  12. 数据导出
------------------------------------------------------------------------------*/

* 保存处理后的数据
save "../dataset/auto_processed.dta", replace

* 导出为CSV格式
export delimited using "../dataset/auto_processed.csv", replace

* 导出汇总统计表
preserve
collapse (mean) avg_price=price avg_mpg=miles_per_gallon ///
         (sd) sd_price=price sd_mpg=miles_per_gallon ///
         (count) n=price, by(foreign)
list
export delimited using "../dataset/auto_summary.csv", replace
restore

/*------------------------------------------------------------------------------
  生成LaTeX主文档
------------------------------------------------------------------------------*/
* 创建LaTeX主文档，包含所有表格
file open latexmain using "../dataset/latex/main_tables.tex", write replace
file write latexmain "\documentclass[12pt,a4paper]{article}" _n
file write latexmain "\usepackage[utf8]{inputenc}" _n
file write latexmain "\usepackage[T1]{fontenc}" _n
file write latexmain "\usepackage{booktabs}" _n
file write latexmain "\usepackage{graphicx}" _n
file write latexmain "\usepackage{float}" _n
file write latexmain "\usepackage{caption}" _n
file write latexmain "\usepackage[margin=2.5cm]{geometry}" _n
file write latexmain "\usepackage{ctex}  % 支持中文" _n
file write latexmain "" _n
file write latexmain "\title{Auto数据集分析报告}" _n
file write latexmain "\author{Stata分析}" _n
file write latexmain "\date{\today}" _n
file write latexmain "" _n
file write latexmain "\begin{document}" _n
file write latexmain "" _n
file write latexmain "\maketitle" _n
file write latexmain "\tableofcontents" _n
file write latexmain "\newpage" _n
file write latexmain "" _n
file write latexmain "\section{描述性统计}" _n
file write latexmain "\input{descriptive_stats.tex}" _n
file write latexmain "" _n
file write latexmain "\section{按产地分组统计}" _n
file write latexmain "\input{summary_by_origin.tex}" _n
file write latexmain "" _n
file write latexmain "\section{交叉表分析}" _n
file write latexmain "\input{crosstab_price_origin.tex}" _n
file write latexmain "" _n
file write latexmain "\section{相关系数矩阵}" _n
file write latexmain "\input{correlation_matrix.tex}" _n
file write latexmain "" _n
file write latexmain "\section{回归分析结果}" _n
file write latexmain "\input{regression_results.tex}" _n
file write latexmain "" _n
file write latexmain "\end{document}" _n
file close latexmain

/*------------------------------------------------------------------------------
  13. 最终数据概览
------------------------------------------------------------------------------*/
* 显示处理后的数据结构
describe
summarize

* 显示新生成的变量
list make price price_category miles_per_gallon mpg_rating foreign in 1/15

/*------------------------------------------------------------------------------
  结束
------------------------------------------------------------------------------*/
* 关闭日志
log close

display "==============================================="
display "数据处理完成！"
display "==============================================="
display ""
display "数据文件："
display "  - 处理后的数据: ../dataset/auto_processed.dta"
display "  - CSV格式: ../dataset/auto_processed.csv"
display ""
display "分析图表（共8张）："
display "  - 价格分布直方图: ../dataset/graphs/price_histogram.png"
display "  - 价格箱线图: ../dataset/graphs/price_by_origin_boxplot.png"
display "  - 油耗与重量散点图: ../dataset/graphs/mpg_weight_scatter.png"
display "  - 油耗对比图: ../dataset/graphs/mpg_by_price_origin.png"
display "  - 价格与油耗散点图: ../dataset/graphs/price_mpg_scatter.png"
display "  - 价格分类饼图: ../dataset/graphs/price_category_pie.png"
display "  - 重量分布图: ../dataset/graphs/weight_histogram_by_origin.png"
display "  - 维修记录条形图: ../dataset/graphs/repair_record_bar.png"
display ""
display "结果表（共5个）："
display "  CSV格式："
display "    - 描述性统计: ../dataset/descriptive_stats.csv"
display "    - 分组汇总: ../dataset/summary_by_origin.csv"
display "    - 交叉表: ../dataset/crosstab_price_origin.csv"
display "    - 相关系数矩阵: ../dataset/correlation_matrix.xlsx"
display "    - 回归分析结果: ../dataset/regression_results.csv"
display ""
display "  LaTeX格式："
display "    - 描述性统计: ../dataset/latex/descriptive_stats.tex"
display "    - 分组汇总: ../dataset/latex/summary_by_origin.tex"
display "    - 交叉表: ../dataset/latex/crosstab_price_origin.tex"
display "    - 相关系数矩阵: ../dataset/latex/correlation_matrix.tex"
display "    - 回归分析结果: ../dataset/latex/regression_results.tex"
display "    - LaTeX主文档: ../dataset/latex/main_tables.tex"
display ""
display "LaTeX编译说明："
display "  进入 ../dataset/latex/ 目录，运行："
display "  xelatex main_tables.tex"
display "  (需要安装ctex宏包以支持中文)"
display ""
display "==============================================="

/*==============================================================================
  脚本说明：

  本脚本演示了以下Stata数据处理操作：
  1. 数据加载和基本探索
  2. 缺失值检查和处理
  3. 新变量生成和转换
  4. 数据分组和汇总统计
  5. 数据排序和筛选
  6. 变量重命名和标签管理
  7. 交叉表分析
  8. 条件统计
  9. 生成分析图表（8张图）
  10. 生成结果表（5个表）
  11. 数据导出（Stata格式和CSV格式）

  输出内容：
  - 8张分析图表（PNG格式，保存在 dataset/graphs/）
  - 5个结果表（CSV/XLSX格式，保存在 dataset/）
  - 5个LaTeX表格（TEX格式，保存在 dataset/latex/）
  - 1个LaTeX主文档（main_tables.tex，可直接编译）
  - 处理后的数据文件

  运行方式：
  在Stata命令窗口中输入: do do/auto_analysis.do

  注意：
  - 本脚本使用Stata内置命令，无需安装额外包
  - 所有表格导出使用原生file命令和矩阵操作

  LaTeX编译：
  - 进入 dataset/latex/ 目录
  - 运行: xelatex main_tables.tex
  - 需要安装ctex宏包以支持中文
  - 需要安装booktabs宏包以美化表格
==============================================================================*/

